<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/views/shared/taglib.jsp"%>
<%
	request.setAttribute("title", "活动详情");
%>
<%@ include file="/WEB-INF/views/shared/master/weContentHeader.jsp"%>
<%@ include file="/WEB-INF/views/shared/master/weTitle.jsp"%>

<%@ include file="/WEB-INF/views/shared/scripts/jquery.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/jqweui.jsp"%>
<%@ include file="/WEB-INF/views/shared/scripts/swiper.jsp"%>
<style type="text/css">
body{
	background-color: #f5f5f5;
}

.titleleft {
	font-family: SimSun;
	font-weight: bold;
	color: black;
}

.titleright {
	color: gray;
}

.activitydiv1>span {
	color: #7B68EE;
	padding-left: 15px;
	padding-top: 50px;
}

.list_lh {
	height: 400px;
	overflow: hidden;
}

.list_lh li {
	padding: 10px;
	background: #e5e5e5;
	border-bottom: 1px solid #fff;
}

.list_lh li p {
	height: 24px;
	line-height: 24px;
	margin-left: 15px;
}

.list_lh li p a {
	float: left;
}

.list_lh li p em {
	width: 80px;
	font: normal 12px/24px Arial;
	color: #FF3300;
	float: right;
	display: inline-block;
}

.list_lh li p span {
	color: #999;
	float: right;
}

.list_lh li p a.btn_lh {
	background: #28BD19;
	height: 17px;
	line-height: 17px;
	color: #fff;
	padding: 0 5px;
	margin-top: 4px;
	display: inline-block;
	float: right;
}

.btn_lh:hover {
	color: #fff;
	text-decoration: none;
}

.top {
	border-radius: 5px;
/* 	height: 45px;
 */	margin: 10px 6px;
	background-color: white;
	border-bottom: 3px solid #dcdcdc;
}

.weui-btn_primary {
    background-color: #2196F3;
}

/* =============================== */
.service-award {
	border-top: 2px solid #eee;
}

#shareLevel {
	display: none;
}
.weui-cell:before{
	border-top: 0px;
}
#roll {
	height: 55px;
	overflow: hidden;
}
.weui-cell{
	background-color: #ffffff;
}
</style>

<div class="goback " data-back-href="<c:url value='/wechat/acti/activity'/>"></div>
<input type="hidden" name="level" id="level" value="${level}" />
<input type="hidden" name="joinDateBetween" id="joinDateBetween" value="${joinDateBetween}" />
<input type="hidden" name="signs" id="signs" value="${activity.signs}" />
<input type="hidden" name="dateBetween" id="dateBetween" value="${activity.dateBetween}" />

	<div style="background-color: #ffffff;">
		<img style="width: 100%" alt="" src="<c:url value='${tfn:getFileUrl(activity.actiImg) }' />">
	</div>
	<div class="weui-cell" style="padding-top: 5px;">
	    <div class="weui-cell__bd timeChange" style="color:#666666">
	      
	    </div>
	    <div class="weui-cell__ft label-color" >  
	    	<span class="titleright">${viewTime.viewtimes}&nbsp;人参加</span>
	    </div>
	</div>
	<input class="startDate" type="hidden" value='<fmt:formatDate value="${activity.startDate}" pattern="yyyy/MM/dd HH:mm:ss"/>'/>
	<input class="endDate" type="hidden" value='<fmt:formatDate value="${activity.endDate}" pattern="yyyy/MM/dd  HH:mm:ss" />'/>


<!-- =============================================================================== -->

<div style="border: 1px solid #f5f5f5;">
	<div class="weui-cell weui-cell_access share-award" id="share-father">
		<div class="weui-cell__bd" style="color: #1fa0db !important">
			${activity.content}
		</div>
		<div class="weui-cell__ft label-color"></div>
	</div>
	<div id="shareLevel">
		<div class="weui-cell">
	    	<div class="weui-cell__bd">
				<p>活动对象</p>
	    	</div>
	    	<div class="weui-cell__ft label-color">
	    		${activity.object}
	    	</div>
		</div>
		<div class="weui-cell">
	    	<div class="weui-cell__bd">
	      		<p>活动总奖金</p>
	    	</div>
	    	<div class="weui-cell__ft label-color">
				${activity.reward}		    
			</div>
		</div>	  
		<div class="weui-cell">
	    	<div class="weui-cell__bd">
	      		<p>活动兑换</p>
	    	</div>
	    	<div class="weui-cell__ft label-color">
	   			${activity.exchange}
	    	</div>
		</div>
		<div class="weui-cell">
	    	<div class="weui-cell__bd">
	      		<p>活动时间</p>
	    	</div>
	    	<div class="weui-cell__ft label-color" >  
	    		<fmt:formatDate value="${activity.startDate}" pattern="yyyy/MM/dd" /> 
	    			至
				<fmt:formatDate value="${activity.endDate}" pattern="yyyy/MM/dd" />
	    	</div>
		</div>			
		<div style="width: 100%; height: 15px; background-color: #f5f5f5; padding: 0px"></div>
	</div>
</div>

<!-- ======================================================================================= -->

<div class="weui-cell" style="margin: 15px 0px;border: 1px solid #f5f5f5;border-radius:0.7rem;">
	<div class="weui-cell__hd"></div>
	<div class="weui-cell__bd" id="roll">
		<c:forEach items="${actiRewards}" var="actiRewards">
			<div style="margin-top: 8px">
				<span style="color: #333333">恭喜用户 </span>
				<strong style="color: black">${actiRewards.userName}</strong>
				<span style="color: #333333; margin-left: 5px; margin-right: 5px;">抽中</span>
				<span style="color: red">${actiRewards.reward}</span>
				 <span style="color: #333333">元红包奖励</span>
			</div>
		</c:forEach>
	</div>
</div>

<button type="button" onclick="toRegister()" class="weui-btn weui-btn_primary" style="width: 95%; margin-top: 15px">去注册</button>



<script type="text/javascript">
	$(function() {
		
		setInterval("timeChange()",1000);
		
		var dateBetween = $("#dateBetween").val();
		if(dateBetween=="0"){
			window.location.href=$.getVirtualPath() + "/wechat/acti/activity";
		}
		$(".swiper-container").swiper({
			pagination : '.swiper-pagination',
			paginationClickable : true,
			autoplay : 4000
		});
		movedown();
	})
	
	//倒计时函数
	function timeChange() {
		console.log("调用");
		//开始时间
		var date1=$(".startDate").val(); 
		var begintime_ms = Date.parse(new Date(date1.replace(/-/g, "/"))); //begintime 为开始时间 
	
		//结束时间
		var date2=$(".endDate").val();
		var endtime_ms = Date.parse(new Date(date2.replace(/-/g, "/")));   // endtime 为结束时间  
	
		//当前时间
		var nowtime_ms = Date.parse(new Date());   // endtime 为结束时间  
	
		//相差时间
		var date3;
		
		var suffix;
		
		if(begintime_ms>nowtime_ms){
			date3 = begintime_ms-nowtime_ms;
			suffix = "&nbsp;开始";
		}else if(begintime_ms<nowtime_ms&&nowtime_ms<endtime_ms){
			date3 = endtime_ms-nowtime_ms;
			suffix = "&nbsp;后结束";
		}else if(endtime_ms<nowtime_ms){
			$(".timeChange").html("该活动已经结束");
			return;
		}
		
		//计算出相差天数  
		var days=Math.floor(date3/(24*3600*1000))  
		   
		//计算出小时数  
		  
		var leave1=date3%(24*3600*1000)    //计算天数后剩余的毫秒数  
		var hours=Math.floor(leave1/(3600*1000))  
	
		//计算相差分钟数  
		var leave2=leave1%(3600*1000)        //计算小时数后剩余的毫秒数  
		var minutes=Math.floor(leave2/(60*1000))
		  
		//计算相差秒数  
		var leave3=leave2%(60*1000)      //计算分钟数后剩余的毫秒数  
		var seconds=Math.round(leave3/1000)
		if(days!=0){
			$(".timeChange").html(days+"天"+hours+"小时"+minutes+"分钟"+seconds+"秒"+suffix);
		}else if(hours!=0){
			$(".timeChange").html(hours+"小时"+minutes+"分钟"+seconds+"秒"+suffix);
		}else if(minutes!=0){
			$(".timeChange").html(minutes+"分钟"+seconds+"秒"+suffix);
		}else if(seconds!=0){
			$(".timeChange").html(seconds+"秒"+suffix);
		}	
	}  

	function movedown() {
		var marginTop = 8;
		var stop = false;
		var interval = setInterval(function() {
			if (stop)
				return;
			$('#roll').children('div').first().animate({
				'margin-top' : marginTop--
			}, 8, function() {
				var $first = $(this);
				if (!$first.is(':animated')) {
					if ((-marginTop) > $first.height()) {
						$first.css({
							'margin-top' : 8
						}).appendTo($('#roll'));
						marginTop = 8;
					}
				}
			});
		}, 100);
		$('#roll > div').mouseover(function() {
			stop = true;
		}).mouseout(function() {
			stop = false;
		});
	}
	
	
	//去注册判断

	function toRegister() {
		var dateBetween = $("#dateBetween").val();
		var signs = $("#signs").val();
		if (signs == "-") {
			alert("该活动暂未开始，敬请期待");
			window.location.href = $.getVirtualPath() + "/wechat/acti/activity";
		} else {
			var actiUrl = "/wechat/cust/customerIden/joinEntrepreneur/";
			var personCenterUrl = "/wechat/cust/personCenter/index";
			var level = $("#level").val();
			if (level == "highMaker") {
				alert("对不起，您无法参与此项活动！")
				window.location.href = $.getVirtualPath() + personCenterUrl;
				return;
			} else if (level == "maker") {
				var joinDateBetween = $("#joinDateBetween").val();
				if (joinDateBetween == "between") {
					alert("温馨提示：" + "\n" + "您已参与该活动，无法再次抽奖");
				} else {
					window.location.href = $.getVirtualPath() + actiUrl;
				}
			} else if (level == "visitor") {
				window.location.href = $.getVirtualPath() + actiUrl;
			}
		}
	}
	
	/* 点击下拉*/
	$("#share-father").on("click", function() {
		if ($(this).attr("class").indexOf("weui-cell_access") > 0) {
			$(this).removeClass("weui-cell_access");
			$(this).addClass("weui-cell_define");
		} else {
			$(this).removeClass("weui-cell_define");
			$(this).addClass("weui-cell_access");
		}

		$("#shareLevel").toggle(800);
	});
</script>


<%@ include file="/WEB-INF/views/shared/master/weContentFooter.jsp"%>
